package leetcode.code1685;

import leetcode.IDebug;

public class Solution implements IDebug {

	public int[] getSumAbsoluteDifferences(int[] nums) {
		int len = nums.length;
		int[] sums = new int[len];
		sums[0] = nums[0];
		for (int i = 1; i < len; i++) {
			sums[i] = sums[i - 1] + nums[i];
		}
		int[] ans = new int[len];
		ans[0] = sums[len - 1] - nums[0] - (len - 1) * nums[0];
		for (int i = 1; i < ans.length; i++) {
			ans[i] = nums[i] * i - sums[i - 1] + sums[len - 1] - sums[i] - (len - i - 1) * nums[i];
		}
		return ans;
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
